﻿namespace Blaze.Editor.AssetValidators
{
    using System;
    using System.Text;
    using Framework.Logging;

    public class ValidatingLogger : ILogger
    {
        #region ILogger Members

        public void Debug(object content)
        {
            UnityEngine.Debug.Log(content);
        }

        public void DebugFormat(string format, params object[] args)
        {
            UnityEngine.Debug.Log(String.Format(format, args));
        }

        public void Error(object content)
        {
            mBuffer.Append(content);
            mBuffer.Append("\n");
        }

        public void ErrorFormat(string format, params object[] args)
        {
            mBuffer.AppendFormat(format, args);
            mBuffer.Append("\n");
        }

        public void Info(object content)
        {
            UnityEngine.Debug.Log(content);
        }

        public void InfoFormat(string format, params object[] args)
        {
            UnityEngine.Debug.Log(String.Format(format, args));
        }

        public void Warning(object content)
        {
            UnityEngine.Debug.LogWarning(content);
        }

        public void WarningFormat(string format, params object[] args)
        {
            UnityEngine.Debug.LogWarning(String.Format(format, args));
        }

        #endregion

        public string CollectErrors()
        {
            var ret = mBuffer.ToString();
            mBuffer = new StringBuilder();
            return ret;
        }

        private StringBuilder mBuffer = new StringBuilder();
    }
}